package infopreserve.main.mobile;

import infopreserve.main.mobile.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ListView;


public class InfoPreserveActivity extends Activity  {
    /** Called when the activity is first created. */
	
	 protected String username;
	 protected String password;
	 protected InfoPreserveActivity file;
	 protected ListView lv;
	 protected Dialog d;

	 	@Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.main);
	 	}
	 	public void onClick(View v) {
	 		EditText editText = (EditText) findViewById(R.id.editText1);
	        InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
	        mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
	 		 username =  ((EditText)findViewById(R.id.editText1)).getText().toString();
	 		EditText editText2 = (EditText) findViewById(R.id.editText2);
	 		 mgr.showSoftInput(editText2, InputMethodManager.SHOW_IMPLICIT);
	 		 password = ((EditText)findViewById(R.id.editText2)).getText().toString();
	         mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);
	 		if(username.equals("") && password.equals("") ){
	 		     Intent intent = new Intent();
	 		     intent.setClass(this,Tab.class);
	 		     startActivity(intent);
	 		     this.finish();
	 		 }
	 		else{
	 			d = new AlertDialog.Builder(InfoPreserveActivity.this)  
	 			.setMessage("Username or Password is Invalid")  
	 			.setPositiveButton(R.string.btn_close, null)
	 			.show();
	 			}
	 		}
	 	}
